package network;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class UDPReceiveTest01 {
    public static void main(String[] args) throws IOException {
        DatagramSocket datagramSocket = new DatagramSocket(10086);

        while (true) {
            byte[] bytes = new byte[1024];
            DatagramPacket packet = new DatagramPacket(bytes, bytes.length);

            datagramSocket.receive(packet);
            byte[] data = packet.getData();
            String s = new String(data, 0, packet.getLength());
            System.out.println(s);
        }
    }
}
